package com.ruoyi.xh.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TablePageDataInfo;
import com.ruoyi.common.core.domain.CommentResult;
import com.ruoyi.xh.domain.XhOrderMoney;
import com.ruoyi.xh.service.IXhOrderMoneyService;

/**
 * 分佣记录Controller
 *
 * @author songjw
 * @date 2024-12-13
 */
@Api(tags = "分佣记录Controller",value = "分佣记录Controller")
@RestController
@RequestMapping("/xh/orderMoney")
public class XhOrderMoneyController extends BaseController {

    @Autowired
    private IXhOrderMoneyService xhOrderMoneyService;

    /**
     * 查询分佣记录列表
     */
    @PreAuthorize("@ss.hasPermi('xh:orderMoney:list')")
    @GetMapping("/list")
    @ApiOperation("查询分佣记录列表")
    public TablePageDataInfo<XhOrderMoney> list(XhOrderMoney xhOrderMoney) {
        return TablePageDataInfo.success(xhOrderMoneyService.selectXhOrderMoneyList(xhOrderMoney));
    }

    /**
     * 获取分佣记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('xh:orderMoney:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取分佣记录详细信息")
    public CommentResult<XhOrderMoney> getInfo(@PathVariable("id") Long id) {
        return CommentResult.success(xhOrderMoneyService.selectXhOrderMoneyById(id));
    }

    /**
     * 新增分佣记录
     */
    @PreAuthorize("@ss.hasPermi('xh:orderMoney:add')")
    @Log(title = "分佣记录", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增分佣记录")
    public CommentResult<XhOrderMoney> add(@RequestBody XhOrderMoney xhOrderMoney) {
            xhOrderMoneyService.insertXhOrderMoney(xhOrderMoney);
        return CommentResult.success();
    }

    /**
     * 修改分佣记录
     */
    @PreAuthorize("@ss.hasPermi('xh:orderMoney:edit')")
    @Log(title = "分佣记录", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改分佣记录")
    public CommentResult<XhOrderMoney> edit(@RequestBody XhOrderMoney xhOrderMoney) {
            xhOrderMoneyService.updateXhOrderMoney(xhOrderMoney);
        return CommentResult.success();
    }

    /**
     * 删除分佣记录
     */
    @PreAuthorize("@ss.hasPermi('xh:orderMoney:remove')")
    @Log(title = "分佣记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation("删除分佣记录")
    public CommentResult<XhOrderMoney> remove(@PathVariable Long[] ids) {
            xhOrderMoneyService.deleteXhOrderMoneyByIds(ids);
        return CommentResult.success();
    }
}
